#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    qDebug()<<"log";

    QPixmap img(":/new/prefix1/pictures/background.jpeg");
    ui->label_background->setPixmap(img);

    connect(ui->pushButton_log,SIGNAL(clicked()),this,SLOT(doLogClient()));

    QPixmap ip_logo(":/new/prefix1/pictures/用户-圆.png");
    ui->label_ip->setPixmap(ip_logo);
    QPixmap port_logo(":/new/prefix1/pictures/密码.png");
    ui->label_port->setPixmap(port_logo);
}

void Widget::doLogClient()
{
    QString txt_ip = ui->lineEdit_ip->text();
    QString txt_port = ui->lineEdit_port->text();

    if((txt_ip != 0) && (txt_port == "1883"))
    {
        qDebug()<<"log ok";
        Form_livingroom *lr = new Form_livingroom;
        lr->connectServer();
        this->hide();
        lr->show();      
    }
    else
    {
        ui->label_log->setText("登录失败！");
        qDebug()<<"log failed";
    }
}

Widget::~Widget()
{
    delete ui;
}
